/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package org.apache.gravitino.listener.api.event;

import org.apache.gravitino.NameIdentifier;
import org.apache.gravitino.annotation.DeveloperApi;
import org.apache.gravitino.listener.api.info.TableInfo;

/** Represents an event triggered upon the successful loading of a table. */
@DeveloperApi
public final class LoadTableEvent extends TableEvent {
  private final TableInfo loadedTableInfo;

  /**
   * Constructs an instance of {@code LoadTableEvent}.
   *
   * @param user The username of the individual who initiated the table loading.
   * @param identifier The unique identifier of the table that was loaded.
   * @param tableInfo The state of the table post-loading.
   */
  public LoadTableEvent(String user, NameIdentifier identifier, TableInfo tableInfo) {
    super(user, identifier);
    this.loadedTableInfo = tableInfo;
  }

  /**
   * Retrieves the state of the table as it was made available to the user after successful loading.
   *
   * @return A {@link TableInfo} instance encapsulating the details of the table as loaded.
   */
  public TableInfo loadedTableInfo() {
    return loadedTableInfo;
  }

  /**
   * Returns the type of operation.
   *
   * @return the operation type.
   */
  @Override
  public OperationType operationType() {
    return OperationType.LOAD_TABLE;
  }
}
